import Immutable from 'immutable';
import _ from 'lodash'

const defaultState = new Immutable.List();

export default function demoReducer(state = defaultState, action) {
  switch(action.type) {
    case 'CREATE_DELIVERY_DATA':
      var data = action.data;
      if (action.response.data.success) {
        var logs = _.concat(state.data, data);
        console.log(logs)
        return _.assign({data: logs}, state);
      }else {
        console.log(action.response.data)
        return state;
      }
    case 'LOAD_DELIVERY_DATA':
      return action.data;
    case 'ERROR_DELIVERY':
      return action.error.status;
    default:
      return state;
  }
}
